﻿package kaze.process.application
{
    import kaze.Application;
    import kaze.ApplicationID;
    import kaze.display.DisplayList;

    import system.events.FrontController;
    import system.process.Initializer;

    import vegas.ioc.factory.ObjectFactory;
    /**
     * This process build the application when all externals assets and configs are loading and initialize.
     */
    public class BuildApplication extends Initializer 
    {
        /**
         * Creates a new BuildApplication instance.
         */
        public function BuildApplication()
        {
            super() ;
        }
        
        /**
         * The ObjectFactory reference of this process.
         */
        public var factory:ObjectFactory ;
        
        /**
         * Invoked when the process is run.
         */
        public function initialize():void 
        {
            logger.debug ( this + " init." ) ; 
            if ( factory )
            {
                // init views
                
                factory.getObject( DisplayList.APPLICATION ) as Application ;
                
                // init controllers
                
                factory.getObject( ApplicationID.FRONT_CONTROLLER ) as FrontController ;
            }
            else
            {
                logger.fatal( this + " init failed if the factory reference is 'null' or 'undefined'.") ;
            }
        }
    }
}
